public class Manage2 {
    private static Manage2 INSTANCE;
    private static int id = 0;

    private Manage2() {
        id++;
    }

    public static Manage2 getInstance() {
        if (INSTANCE == null) {
            try {
                Thread.sleep(1); // 假装new变得很慢，机器卡住了
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            INSTANCE = new Manage2();
        }
        return INSTANCE;
    }

    @Override
    public String toString() {
        return "id=" + id;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                System.out.println(Manage2.getInstance().hashCode());
            }
            ).start();
        }
    }
}
